package com.woniu.dao;

import com.woniu.controller.form.CheckList;
import com.woniu.controller.form.ProductForm;
import com.woniu.model.EProduct;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 拍品表 Mapper 接口
 * </p>
 *
 * @author Kevin Kwok
 * @since 2021-04-16
 */
public interface EProductMapper extends BaseMapper<EProduct> {

    @Select("select ep.product_name,ec.type_name,ep.introduce,ep.status,ep.mode from e_classify ec join e_product ep on ec.id = ep.cid where STATUS!='NO' limit #{start} , #{pagesize}")
    List<ProductForm> showAllCurrent(int start,int pagesize);
    @Select("select count(*) from e_classify ec join e_product ep on ec.id = ep.cid where STATUS!='NO'")
    int countAllRecords();

    @Select("select ep.id as pid,ep.product_name,ep.introduce,ep.image,ep.status,ep.raw_add_time,ec.type_name,eu.username from e_product ep join e_user eu on ep.uid=eu.id join e_classify ec on ep.cid=ec.id where ep.status='NO'")
    List<CheckList> queryAll();

    @Update("update e_product set status='SELL' where id = #{productId}")
    int checkPass(int productId);

    @Update("update e_product set status='ICE' where id = #{productId}")
    int checkRefuse(int productId);

}
